package org.example.aicloud.util;

import org.example.aicloud.entity.SecurityUserDetails;
import org.springframework.security.core.context.SecurityContextHolder;

public class SecurityUtil {
    /**
     * 得到当前登录用户
     *
     * @return
     */
    public static SecurityUserDetails getCurrentUser() {
        SecurityUserDetails userDetails = null;
        try {
            userDetails = (SecurityUserDetails) SecurityContextHolder.getContext()
                    .getAuthentication().getPrincipal();
        } catch (Exception e) {
        }
        return userDetails;
    }
}
